package main

import "strings"
import "awesomeProject/lib"

func main() {
	reverseStr("abcdef", 3)
}

func reverseStr(s string, k int) string {
	sliceA := splitK(s, k)
	var ret []string
	for index, value := range sliceA {
		if index % 2 == 0 {
			ret = append(ret, lib.ReverseWord(value))
		} else {
			ret = append(ret, value)
		}
	}
	return strings.Join(ret, "")
}

func splitK(s string, k int) []string {
	var ret []string
	for i := 0; i < len(s); i = i+k {
		if i + k < len(s) {
			ret = append(ret, s[i:i+k])
		} else {
			ret = append(ret, s[i:])
		}
	}
	return ret
}
